<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var seed = '1234567890asdfghjklqwertyuiozxcvbnm';
        /**
         * 需求：得到一个4位的验证码
         * 
         */

        var code = '';
        function getRandomCode(seed){
            var index = Math.floor(Math.random() * seed.length);
            return seed[index];
        }

        for(var i = 0; i < 4;i++){
            code += getRandomCode(seed)
        }
        console.log('code: ', code);
    </script>
</body>
</html>